---
title: Marks
---

import Parameter from "@site/src/components/Parameter";
import Type from "@site/src/components/Type";

Marks are arrow tips that can be added to the end of path based elements that support the `mark` style key, or can be directly drawn by using the `mark` draw function. Marks are specified by giving their names (or shorthand) as strings and have several options to customise them. You can give an array of names to have multiple marks, and dictionaries can be used in the array for per mark styling.

```typ render
#set page(margin: 0cm)
#align(center, table(
  columns: 3,
  [*Name*], [*Shorthand*], [*Shape*],
  ..(for (name, item) in cetz.mark-shapes.marks {
    let name-to-mnemonic = (:)
    for (name, item) in cetz.mark-shapes.mnemonics {
      let list = name-to-mnemonic.at(item.at(0), default: ())
      list += (raw(name) + if item.at(1).at("reverse", default: false) { " (reversed)" },)
      name-to-mnemonic.insert(item.at(0), list)
    }
    (
      raw(name),
      name-to-mnemonic.at(name, default: ([],)).join([, ]),
      cetz.canvas(cetz.draw.line((), (1, 0), mark: (end: name)))
    )
  })
))
```

```typc example
let c = ((rel: (0, -1)), (rel: (2, 0), update: false)) // Coordinates to draw the line, it is not necessary to understand this for this example.

// No marks
line((), (rel: (1, 0), update: false))

// Draws a triangle mark at both ends of the line.
set-style(mark: (symbol: ">"))
line(..c)

// Overrides the end mark to be a diamond but the start is still a triangle.
set-style(mark: (end: "<>"))
line(..c)

// Draws two triangle marks at both ends but the first mark of end is still a diamond.
set-style(mark: (symbol: (">", ">")))
line(..c)

// Sets the stroke of first mark in the sequence to red but the end mark overrides it to be blue.
set-style(mark: (symbol: ((symbol: ">", stroke: red), ">"), end: (stroke: blue)))
line(..c)
```

---

<Parameter name="symbol" types="none,str,array,dictionary" default_value="none">
  This option sets the mark to draw when using the `mark` draw function, or
  applies styling to both mark ends of path based elements. The mark's name or
  shorthand can be given. Multiple marks can be drawn by passing an array of
  names or shorthands. When `none`, no marks will be drawn. A style{" "}
  <Type>dictionary</Type> can be given instead of a <Type>str</Type> to override
  styling for that particular mark, just make sure to still give the mark name
  using the `symbol` key otherwise nothing will be drawn!
</Parameter>

<Parameter name="start" types="none,str,array,dictionary" default_value="none">
  This option sets the mark to draw at the start of a path based element. It
  will override all options of the `symbol` key and will not affect marks drawn
  using the `mark` draw function.
</Parameter>

<Parameter name="end" types="none,str,array,dictionary" default_value="none">
  Like `start` but for the mark at the end of a path.
</Parameter>

<Parameter name="length" types="number" default_value="0.2cm">
  The size of the mark in the direction it is pointing.
</Parameter>

<Parameter name="width" types="number" default_value="0.15cm">
  The size of the mark along the normal of its direction.
</Parameter>

<Parameter name="inset" types="number" default_value="0.05cm">
  It specifies a distance by which something inside the arrow tip is set
  inwards; for the stealth arrow tip it is the distance by which the back angle
  is moved inwards.
</Parameter>

<Parameter name="scale" types="float" default_value="1">
  A factor that is applied to the mark's length, width and inset.
</Parameter>

<Parameter name="sep" types="number" default_value="0.1cm">
  The distance between multiple marks along their path.
</Parameter>

<Parameter name="position-samples" types="int" default_value="30">
  Only applicable when marks are used on curves such as bezier and hobby. The
  maximum number of samples to use for calculating curve positions. A higher
  number gives better results but may slow down compilation
</Parameter>

<Parameter name="pos" types="number,ratio,none" default_value="none">
  Overrides the mark's position along a path. A number will move it an absolute
  distance, while a ratio will be a distance relative to the length of the path.
  Note that this may be removed in the future in preference of a different
  method.
</Parameter>

<Parameter name="offset" types="number,ratio,none" default_value="none">
  Like `pos` but it advances the position of the mark instead of overriding it.
</Parameter>

<Parameter name="anchor" types="str" default_value="tip">
  Anchor to position the mark at. Can be one of `base`, `center` or `tip`.
</Parameter>

<Parameter name="slant" types="ratio" default_value="0%">
  How much to slant the mark relative to the axis of the arrow. 0% means no
  slant 100% slants at 45 degrees.
</Parameter>

<Parameter name="harpoon" types="bool" default_value="false">
  When true only the top half of the mark is drawn.
</Parameter>

<Parameter name="flip" types="bool" default_value="false">
  When true the mark is flipped along its axis.
</Parameter>

<Parameter name="reverse" types="bool" default_value="false">
  Reverses the direction of the mark.
</Parameter>

<Parameter name="xy-up" types="vector" default_value="(0, 0, 1)">
  The direction which is "up" for use when drawing 2D marks.
</Parameter>

<Parameter name="z-up" types="vector" default_value="(0, 1, 0)">
  The direction which is "up" for use when drawing 3D marks.
</Parameter>

<Parameter name="shorten-to" types="int,auto,none" default_value="auto">
  Which mark to shorten the path to when multiple marks are given. `auto` will
  shorten to the last mark, `none` will shorten to the first mark (effectively
  disabling path shortening). An integer can be given to select the mark's
  index.
</Parameter>

<Parameter name="transform-shape" types="bool" default_value="true">
  When `false` marks will not be stretched/affected by the current
  transformation, marks will be placed after the path is transformed.
</Parameter>
